package it.gestionedocumentale.struts.action;

import it.gestionedocumentale.utility.UtilityDate;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class LogoutAction extends Action {
	
	private static Log log = LogFactory.getLog(LogoutAction.class);
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		 String dataAccesso = new String();
		    dataAccesso = UtilityDate.getDateAsString(UtilityDate.today(), "dd/MM/yyyy HH:mm:ss.SSS");
		
		log.info("Logout di: "+ request.getSession().getAttribute("utenteSession") +"\n in data: "+ dataAccesso);
		
		request.getSession().invalidate();
		return mapping.findForward("logout");
	}
}